<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI 放置（Droppable） - 默认功能</title>
  <link rel="stylesheet" href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
  <script src="//apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
  <script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<!--  <link rel="stylesheet" href="jqueryui/style.css">-->
  <style>
  #draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
  #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; }
  </style>
  <script>
  $(function() {
  	function ff(v){
  		return JSON.stringify(v);
  	}
    $( "#draggable" ).draggable(
//  	{ revert: "invalid" }
    	//valid 当被放置在目标上时还原,invalid当未被放置在目标上时还原
    );//被拖拽元素
    $( "#droppable" ).droppable({//放置的容器
    	 accept: "#draggable",//接受被放置的选择器
      activeClass: "ui-state-hover",//选中时容器样式
      hoverClass: "ui-state-active",//放置后容器的样式
      drop: function( event, ui ) {//放置后的回调函数
      	//ui 被拖拽进来的元素
//    	console.log(event)
//    	console.log(ui)
//    	console.log(ff(event))
//    	console.log(ff(ui))
      	console.log($(this).html())
//		var dd = $(ui.draggable);
//		console.log(dd.attr("id"))
        $( this )
          .addClass( "ui-state-highlight" )
          .find( "p" )
            .html( "Dropped!" );
//             return false;   //为true时阻止事件传播。默认为true,droppable嵌套时可用。
      }
    });
  });
  </script>
</head>
<body>
 
<div id="draggable" class="ui-widget-content">
  <p>请把我拖拽到目标处！</p>
</div>
 
<div id="droppable" class="ui-widget-header">
  <p>请放置在这里！</p>
</div>
 
 
</body>
</html>